package com.tech.koufu.ui.activity.setting;

import com.tech.koufu.MyApplication;
import com.tech.koufu.R;
import com.tech.koufu.tools.KouFuTools;
import com.tech.koufu.tools.PublicFuc;
import com.tech.koufu.tools.SharedConfig;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class SettingActivity extends Activity{
	
	//个人信息，密码修改，行情刷新频率，切换账号，关于，检测更新，意见反馈，常见问题
	private LinearLayout ly_userinfo,ly_changepwd,ly_refrushkline,
	ly_changeuser,ly_about,ly_updateapp,ly_advicereport,ly_faq;
	private ImageView img_callback;
	private TextView tv_title;
	private Button btn_toregister;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_setting);
		initView();
	}
	
	private void initView(){
		myOnclickListener myOnclick = new myOnclickListener();
		tv_title = (TextView)findViewById(R.id.tv_title);
		tv_title.setText("设置");
		tv_title.setVisibility(View.VISIBLE);
		img_callback = (ImageView)findViewById(R.id.img_callback);
		img_callback.setVisibility(View.VISIBLE);
		img_callback.setOnClickListener(myOnclick);
		ly_userinfo = (LinearLayout)findViewById(R.id.ly_userinfo);
		ly_changepwd = (LinearLayout)findViewById(R.id.ly_changepwd);
		ly_refrushkline = (LinearLayout)findViewById(R.id.ly_refrushkline);
		ly_changeuser = (LinearLayout)findViewById(R.id.ly_changeuser);
		ly_about = (LinearLayout)findViewById(R.id.ly_about);
		ly_updateapp = (LinearLayout)findViewById(R.id.ly_updateapp);
		ly_advicereport = (LinearLayout)findViewById(R.id.ly_advicereport);
		ly_faq = (LinearLayout)findViewById(R.id.ly_faq);
		ly_changepwd.setOnClickListener(myOnclick);
		ly_advicereport.setOnClickListener(myOnclick);
		ly_about.setOnClickListener(myOnclick);
		btn_toregister = (Button) findViewById(R.id.btn_toregister);
		btn_toregister.setOnClickListener(myOnclick);
	}

	private class myOnclickListener implements OnClickListener{

		@Override
		public void onClick(View v) {
			Intent intent = new Intent();
			switch (v.getId()) {
			case R.id.ly_changepwd:
				intent.setClass(getApplicationContext(), ChangePwdActivity.class);
				startActivity(intent);
				break;
			case R.id.ly_advicereport:
				intent.setClass(getApplicationContext(), AdviceReportActivity.class);
				startActivity(intent);
				break;
			case R.id.ly_about:
				intent.setClass(getApplicationContext(), AboutActiviity.class);
				startActivity(intent);
				break;
			case R.id.img_callback:
				SettingActivity.this.finish();
				break;
			case R.id.btn_toregister:
				MyApplication myApp = (MyApplication) getApplication();
				myApp.setUserid("");
				myApp.setUserName("");
				myApp.setGroupId("");
				myApp.setDigitalid("");
				myApp.setUserpwd(""); 
				myApp.phpsessid = "";
				myApp.isLogin = false;
				//删除文件
				SharedConfig.clearLoginStatus(getApplicationContext());
				setResult(PublicFuc.CODE_Back);
				SettingActivity.this.finish(); 
				break;
			default:
				break;
			}
		}
		
	}
}
